<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">
		<style>
			.imgsrc{
			/* 	width: 300px;
				height: 300px; */
			}
			.layui-table-cell {
				height: 75px;
				line-height: 75px;
			}
		</style>
	</head>
	<body>
		<div class="layui-fluid">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card">
						<!-- <div class="layui-card-header">商户进件</div> -->
						<div class="layui-tab layui-tab-brief" lay-filter="changetab">
							<ul class="layui-tab-title" id="view_ul"></ul>
							<div class="layui-card-body">
								<!-- 搜索 -->
								<form class="layui-form search" id="form" onsubmit="return false" action="##">
									<div class="layui-inline search_inline">
										<label class="layui-form-label">时间选择：</label>
										<div class="layui-input-inline">
											<input class="layui-input" id="choosetime" style="width: 300px;"
												placeholder="时间选择" autocomplete="off">
											<input class="layui-input" type="text" name="starttime" placeholder=""
												autocomplete="off" style="display: none;">
											<input class="layui-input" type="text" name="endtime" placeholder=""
												autocomplete="off" style="display: none;">
										</div>
									</div>
									<div class="layui-inline search_inline">
										<label class="layui-form-label">商户名称：</label>
										<div class="layui-input-inline">
											<input class="layui-input" lay-verify="" placeholder="商户名称" name="merchantname" autocomplete="off">
										</div>
									</div>
									<button class="layui-btn search_inline" lay-submit="" lay-filter="search" data-type="reload">搜索</button>
									<button class="layui-btn layui-btn-primary search_inline" type="reset">重置</button>
								</form>
								<!-- 搜索 -->

								<table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate"></table>
								<!-- <script type="text/html" id="test-table-operate-barDemo1">
									<a class="layui-btn layui-btn-default layui-btn-xs" lay-event="audit">修改</a>
								</script> -->
								<script type="text/html" id="zizeng">
									{{d.LAY_TABLE_INDEX+1}}
								</script>
								<script type="text/html" id="test-table-operate-barDemo">
									<!-- <a class="layui-btn layui-btn-xs" lay-event="detail">详情</a> -->
									<a class="layui-btn layui-btn-xs" lay-event="edit">修改</a>
								  <!-- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
								  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> -->
								</script>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/html" id="demo_ul">
			<li lay-id=''>全部</li>
			<li class="layui-this" lay-id='0'>未提交</li>
			<li class="" lay-id='1'>已提交</li>
			<li class="" lay-id='2'>审核中</li>
			<li class="" lay-id='3'>待实名</li>
			<li class="" lay-id='4'>已完成</li>
			<li class="" lay-id='-1'>未通过</li>
			<li class="" lay-id='-2'>审核失败</li>
			<!-- {{# layui.each(d, function(index, item){ }}
				<li class="" lay-id='{{ item.value }}'>{{ item.name }}</li>
				{{# }); }} -->
		</script>

		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../../js/common.js"></script>
		<script>
			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'table', 'form','laydate'], function() {
				var table = layui.table,
					$ = layui.$,
					laydate = layui.laydate,
					form = layui.form,
					element = layui.element,
					admin = layui.admin;

				var _data = {}
				var getTpl = demo_ul.innerHTML,
				view = document.getElementById('view_ul');
				view.innerHTML = getTpl;
				record_type_show('option');
				var alldata={}
				var billdata=[]
				initdata();

				function initdata() {
					table.render({
						elem: '#test-table-operate',
						url: server.query_merchant_in,
						height: 'full-105',
						defaultToolbar: [  'exports', {
							title: '提示' //标题
							, layEvent: 'LAYTABLE_TIPS' //事件名，用于 toolbar 事件中使用
							, icon: 'layui-icon-tips' //图标类名
						}],
						toolbar: true,
						cols: [
							[{
								width: 50,
								field: 'zizeng',
								title: '#',
								fixed: 'left',
								templet: '#zizeng'
							},
							{
								width: 170,
								align: 'center',
								fixed: 'right',
								toolbar: '#test-table-operate-barDemo',
								title: '操作',
								fixed: 'left'
							},
							{
								field: 'memberid',
								width: 100,
								title: '会员编号',
								//totalRowText: '合计',
							},{
								field: 'shopid',
								width: 100,
								title: '店铺编号',
							},{
								field: 'membername',
								width: 100,
								title: '会员名称',
							},
							{
								field: 'type',
								width: 150,
								title: '商户身份',
								templet: function(d) {
									return d.billdata.type==0?'特约商户':'小微商户'
								}
							},
							{
								width: 180,
								title: '商户营业执照',
								align: 'center',
								// field: 'goods_thumbnail_url',
								// toolbar: '#test-table-operate-img',
								templet: function(d) {
									return d.billdata.type=='0'?"<img class='imgsrc' src="+d.billdata.file_info.license_pic_file+">":""
								}
							},
							{
								field: 'reg_name',
								width: 260,
								title: '商户注册名称',
								templet: function(d) {
									return d.billdata.reg_name
								}
							},
							{
								field: 'license_code',
								width: 260,
								title: '营业执照编号',
								templet: function(d) {
									return d.billdata.type=='0'?d.billdata.license_code:""
								}
							},
							{
								field: 'license_code',
								width: 260,
								title: '营业执照类型',
								templet: function(d) {
									return d.billdata.type=='0'?(d.billdata.license_type==1?'营业执照(多证合一)':d.billdata.license_type=='NATIONAL_LEGAL'?'营业执照':d.billdata.license_type==3?'事业单位法人证书':''):""
								}
							},
							{
								field: 'license_code',
								width: 260,
								title: '证照有效期',
								templet: function(d) {
									return d.billdata.type=='0'?(d.billdata.license_validity_type==1?d.billdata.license_begin_date+'~长期':d.billdata.license_begin_date+'~'+d.billdata.license_end_date):""
								}
							},
							{
								field: 'ent_type',
								width: 260,
								title: '公司类型',
								templet: function(d) {
									return d.billdata.ent_type==3?'私营企业':d.billdata.ent_type==5?'个体工商户':''
								}
							},
							{
								field: 'reg_addrs',
								width: 260,
								title: '商户注册地址',
								templet: function(d) {
									return d.billdata.reg_addrs
								}
							},
							{
								field: 'reg_detail',
								width: 260,
								title: '注册详细地址',
								templet: function(d) {
									return d.billdata.reg_detail
								}
							},
							{
								field: 'addrs',
								width: 260,
								title: '商户经营地区',
								templet: function(d) {
									return d.billdata.addrs
								}
							},
							{
								field: 'detail_addr',
								width: 260,
								title: '经营详细地址',
								templet: function(d) {
									return d.billdata.detail_addr
								}
							},
							{
								field: 'detail_addr',
								width: 260,
								title: '法人身份证人像面',
								templet: function(d) {
									return d.billdata.type=='0'?"<img class='imgsrc' src="+d.billdata.file_info.legal_cert_front_pic_file+">":""
								}
							},
							{
								field: 'detail_addr',
								width: 260,
								title: '法人身份证国徽面',
								templet: function(d) {
									return d.billdata.type=='0'?"<img class='imgsrc' src="+d.billdata.file_info.legal_cert_back_pic_file+">":""
								}
							},
							{
								field: 'ent_type',
								width: 260,
								title: '法人证件类型',
								templet: function(d) {
									return d.billdata.legal_info? (d.billdata.legal_info.legal_cert_type=='00'?'身份证':d.billdata.legal_info.legal_cert_type=='01'?'护照':d.billdata.legal_info.legal_cert_type=='11'?'港澳台通行证':'其他'):''
								}
							},
							{
								field: 'legal_name',
								width: 260,
								title: '法人姓名',
								templet: function(d) {
									return d.billdata.legal_info? d.billdata.legal_info.legal_name:''
								}
							},
							{
								field: 'legal_cert_no',
								width: 260,
								title: '证件号码',
								templet: function(d) {
									return d.billdata.legal_info?d.billdata.legal_info.legal_cert_no:''
								}
							},
							{
								field: 'license_code',
								width: 260,
								title: '证件照有效期',
								templet: function(d) {
									return d.billdata.legal_info?(d.billdata.legal_info.legal_cert_validity_type==1?d.billdata.legal_info.legal_cert_begin_date+'~长期':d.billdata.legal_info.legal_cert_begin_date+'~'+d.billdata.legal_info.legal_cert_end_date):""
								}
							},
							{
								field: 'short_name',
								width: 260,
								title: '商户简称',
								templet: function(d) {
									return d.billdata.short_name
								}
							},
							{
								field: 'service_phone',
								width: 260,
								title: '客服电话',
								templet: function(d) {
									return d.billdata.service_phone
								}
							},
							{
								field: 'contact_name',
								width: 260,
								title: '联系人姓名',
								templet: function(d) {
									return d.billdata.contact_info.contact_name
								}
							},
							{
								field: 'contact_mobile_no',
								width: 260,
								title: '联系人手机号',
								templet: function(d) {
									return d.billdata.contact_info.contact_mobile_no
								}
							},
							{
								field: 'contact_email',
								width: 260,
								title: '联系人邮箱',
								templet: function(d) {
									return d.billdata.contact_info.contact_email
								}
							},
							{
								field: 'contact_email',
								width: 260,
								title: '身份证人像面',
								templet: function(d) {
									return "<img class='imgsrc' src="+d.billdata.file_info.identification_front_pic_file+">"
								}
							},
							{
								field: 'contact_email',
								width: 260,
								title: '身份证国徽面',
								templet: function(d) {
									return "<img class='imgsrc' src="+d.billdata.file_info.identification_back_pic_file+">"
								}
							},
							{
								field: 'ent_type',
								width: 260,
								title: '证件类型',
								templet: function(d) {
									return d.billdata.card_info.cert_type=='00'?'身份证':d.billdata.card_info.cert_type=='01'?'护照':d.billdata.card_info.cert_type=='11'?'港澳台通行证':'其他'
								}
							},
							{
								field: 'reg_name',
								width: 260,
								title: '姓名',
								templet: function(d) {
									return d.billdata.reg_name
								}
							},
							{
								field: 'contact_cert_no',
								width: 260,
								title: '证件号码',
								templet: function(d) {
									return d.billdata.contact_info.contact_cert_no
								}
							},
							{
								field: 'contact_name',
								width: 260,
								title: '联系人姓名',
								templet: function(d) {
									return d.billdata.contact_info.contact_name
								}
							},
							{
								field: 'contact_mobile_no',
								width: 260,
								title: '手机号',
								templet: function(d) {
									return d.billdata.contact_info.contact_mobile_no
								}
							},
							{
								field: 'contact_email',
								width: 260,
								title: '电子邮箱',
								templet: function(d) {
									return d.billdata.contact_info.contact_email
								}
							},
							{
								field: 'contact_email',
								width: 260,
								title: '门店名称',
								templet: function(d) {
									return d.billdata.short_name
								}
							},
							{
								field: 'addrs',
								width: 260,
								title: '门店位置',
								templet: function(d) {
									return d.billdata.addrs
								}
							},
							{
								field: 'detail_addr',
								width: 260,
								title: '门店详细地址',
								templet: function(d) {
									return d.billdata.detail_addr
								}
							},
							{
								field: 'mcc',
								width: 260,
								title: '所属行业',
								templet: function(d) {
									return d.billdata.mcc=='5399'?'5399-生活百货-百货商城-其他综合零售':''
								}
							},
							{
								field: 'reg_acct_pic_file',
								width: 260,
								title: '开户许可证',
								templet: function(d) {
									return (d.billdata.ent_type=='3')?"<img class='imgsrc' src="+d.billdata.file_info.reg_acct_pic_file+">":""
								}
							},
							{
								field: 'settle_card_front_pic_file',
								width: 260,
								title: '银行卡正面',
								templet: function(d) {
									return "<img class='imgsrc' src="+d.billdata.file_info.settle_card_front_pic_file+">"
								}
							},
							{
								field: 'settle_card_back_pic_file',
								width: 260,
								title: '银行卡反面',
								templet: function(d) {
									return "<img class='imgsrc' src="+d.billdata.file_info.settle_card_back_pic_file+">"
								}
							},
							{
								field: 'card_type',
								width: 260,
								title: '银行账户类型',
								templet: function(d) {
									return d.billdata.card_info.card_type==0?'对公':'对私法人'
								}
							},
							{
								field: 'card_name',
								width: 260,
								title: '银行账户名称',
								templet: function(d) {
									return d.billdata.card_info.card_name
								}
							},
							{
								field: 'card_no',
								width: 260,
								title: '银行账户号',
								templet: function(d) {
									return d.billdata.card_info.card_no
								}
							},
							{
								field: 'branch_code',
								width: 260,
								title: '联行号',
								templet: function(d) {
									return d.billdata.card_info.branch_code
								}
							},
							{
								field: 'branch_code',
								width: 260,
								title: '支行名称',
								templet: function(d) {
									return d.billdata.card_info.branch_name
								}
							},
							{
								field: 'addrss',
								width: 260,
								title: '银行开户地区',
								templet: function(d) {
									return d.billdata.card_address
								}
							},
							{
								field: 'addrss',
								width: 260,
								title: '银行名称',
								templet: function(d) {
									return d.billdata.card_info.bank_code
								}
							},
							{
								field: 'mp',
								width: 260,
								title: '卡绑定手机号',
								templet: function(d) {
									return d.billdata.card_info.mp
								}
							},
							{
								field: 'mp',
								width: 260,
								title: '结算周期',
								templet: function(d) {
									return d.billdata.settle_config.settle_cycle
								}
							},
							{
								field: 'mp',
								width: 260,
								title: '微信所属行业',
								templet: function(d) {
									return d.billdata.wx_conf_list[0].mcc
								}
							},
							{
								field: 'mp',
								width: 260,
								title: '支付宝所属行业',
								templet: function(d) {
									return d.billdata.ali_conf_list[0].mcc
								}
							},
							{
								field: 'store_header_pic_file',
								width: 260,
								title: '店铺门头照',
								templet: function(d) {
									return "<img class='imgsrc' src="+d.billdata.file_info.store_header_pic_file+">"
								}
							},
							{
								field: 'store_cashier_desk_pic_file',
								width: 260,
								title: '店铺收银台',
								templet: function(d) {
									return "<img class='imgsrc' src="+d.billdata.file_info.store_cashier_desk_pic_file+">"
								}
							},
							{
								field: 'store_indoor_pic_file',
								width: 260,
								title: '店铺内景照',
								templet: function(d) {
									return "<img class='imgsrc' src="+d.billdata.file_info.store_indoor_pic_file+">"
								}
							},
							{
								field: 'mp',
								width: 260,
								title: '进件备注说明',
								templet: function(d) {
									return d.billdata.remark?d.billdata.remark:"无"
								}
							},
							{
								field: 'merchantname',
								width: 260,
								title: '商户名称',
							},{
								field: 'addtime',
								width: 160,
								title: '进件时间',
							},{
								field: 'edittime',
								width: 160,
								title: '更新时间',
							}]
						],
						page: true,
						where: _data,
						limit: limit,
						limits: limits,
						request: {
							pageName: 'page',
							limitName: 'size',
						},
						parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
						    var all_data=[]
							if(res.code==0&&res.merchant_in){
								all_data=res.merchant_in.data
								all_data.map((item,index)=>{
									item.billdata=JSON.parse(item.billdata)
									item.billdata.wx_conf_list=JSON.parse(item.billdata.wx_conf_list)
									item.billdata.ali_conf_list=JSON.parse(item.billdata.ali_conf_list)
								})
							}
							return {
								"code": res.code, //解析接口状态
								"msg": res.msg, //解析提示文本
								"count": res.merchant_in.pager.total, //解析数据长度
								"data": all_data //解析数据列表
							};
						}
					});
				}

                laydate.render({
					elem: '#choosetime',
					type: 'date',
					range: true,
					done: function(value, date) {
						$('input[name=starttime]').val(value.split(' - ')[0]);
						$('input[name=endtime]').val(value.split(' - ')[1]);
					}
				});
				//监听搜索
				form.verify({
					memberid: function(value, item) { //value：表单的值、item：表单的DOM对象
						if (!value) {
							return '姓名不能为空';
						}
					}
				});

				//监听搜索
				form.on('submit(search)', function(data) {
					_data = data.field
					initdata();
					return false;
				});

				$("button[type=reset]").on("click", function() {
					_data = {}
					initdata();
					document.getElementById("form").reset();
				});

				//监听表格复选框选择
				table.on('checkbox(test-table-operate)', function(obj) {
					console.log(obj)
				});
				//监听TAB
				element.on('tab(changetab)', function(elem) {
					status = this.getAttribute('lay-id');
					_data.status = status;
					initdata();
				});


				//监听工具条
				table.on('tool(test-table-operate)', function(obj) {
					var data = obj.data;
					if (obj.event === 'detail') {
						layer.open({
							type: 2,
							title: '详情',
							shadeClose: false,
							shade: 0.5,
							area: ['600px', '75%'],
							content: 'model/customer_detail.html?id=' + data.memberid,
							end: function() {
								// initdata();
							}
						});
					} else if (obj.event === 'del') {
						layer.confirm('真的删除行么', function(index) {
							obj.del();
							layer.close(index);
						});
					} else if (obj.event === 'edit') {
						layer.open({
							type: 2,
							title: '修改',
							shadeClose: true,
							shade: false,
							maxmin: true, //开启最大化最小化按钮
							area: ['893px', '600px'],
							content: 'model/merchant_edit.html?id=' + data.id,
							success: function (layero, index) {
								console.log(obj,'dddddddd')
								// billdata=obj.data.billdata
								alldata=obj.data
								// 获取子页面的iframe
								var iframe = window['layui-layer-iframe' + index];
								// 向子页面的全局函数child传参
								iframe.editMerchant(alldata);
							},
							end: function() {

							}
						});
					} else if (obj.event === 'upreport') {
						layer.open({
							type: 2,
							title: '上传报告',
							shadeClose: false,
							shade: 0.5,
							area: ['500px', '300px'],
							content: 'model/up_report.html?id=' + data.id,
							end: function() {}
						});
					}
				});

				var $ = layui.$,
					active = {
						getCheckData: function() { //获取选中数据
							var checkStatus = table.checkStatus('test-table-operate'),
								data = checkStatus.data;
							layer.alert(JSON.stringify(data));
						},
						getCheckLength: function() { //获取选中数目
							var checkStatus = table.checkStatus('test-table-operate'),
								data = checkStatus.data;
							layer.msg('选中了：' + data.length + ' 个');
						},
						isAll: function() { //验证是否全选
							var checkStatus = table.checkStatus('test-table-operate');
							layer.msg(checkStatus.isAll ? '全选' : '未全选')
						}
					};

				$('.test-table-operate-btn .layui-btn').on('click', function() {
					var type = $(this).data('type');
					active[type] ? active[type].call(this) : '';
				});

			});
		</script>
	</body>
</html>
